feat: add Message Translator pattern#246
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Test Results 1 files 1 suites 1m 2s ⏱️ Results for commit 9744bac. |
There was a problem hiding this comment.
Pull request overview
Adds the Message Translator enterprise integration pattern as a first-class slice in PatternKit, including a fluent runtime API, a Roslyn incremental generator + abstractions attributes, and a production-style example (partner event normalization) wired into the examples catalog and docs.
Changes:
- Introduces
MessageTranslator<TInput, TOutput>runtime support with header policies and failure results. - Adds
[GenerateMessageTranslator]source generation (attributes, diagnostics, generator, and tests). - Adds partner event normalization example + DI registration, catalog entries, and documentation.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/PatternKit.Tests/Messaging/Transformation/MessageTranslatorTests.cs | Adds runtime behavior tests for translation, header policies, failures, cancellation, and validation. |
| test/PatternKit.Generators.Tests/MessageTranslatorGeneratorTests.cs | Verifies generated translator factory output and diagnostics PKMT001-003. |
| test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs | Extends attribute coverage tests for new translator attributes. |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs | Updates pattern catalog expectations to include Message Translator. |
| test/PatternKit.Examples.Tests/Messaging/PartnerEventTranslatorExampleTests.cs | Validates fluent vs generated translator paths and DI integration for the example. |
| test/PatternKit.Examples.Tests/DependencyInjection/PatternKitExampleDependencyInjectionTests.cs | Ensures the new example is resolvable and runnable via AddPatternKitExamples(). |
| src/PatternKit.Generators/Messaging/MessageTranslatorGenerator.cs | Implements incremental generator emitting a MessageTranslator<,> factory + PKMT diagnostics. |
| src/PatternKit.Generators/AnalyzerReleases.Unshipped.md | Registers new generator diagnostic IDs (PKMT001-003). |
| src/PatternKit.Generators.Abstractions/Messaging/MessageTranslatorAttributes.cs | Adds generator-facing attributes for translator generation and header policies. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs | Adds Message Translator entry to the production-readiness pattern catalog. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs | Adds “Generated Message Translator” to the examples catalog. |
| src/PatternKit.Examples/Messaging/PartnerEventTranslatorExample.cs | Adds partner event normalization example covering fluent, generated, and DI paths. |
| src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs | Registers the new example into the DI-based example suite. |
| src/PatternKit.Core/Messaging/Transformation/MessageTranslator.cs | Introduces the runtime translator + result type and fluent header policy builder. |
| docs/patterns/toc.yml | Adds Message Translator to patterns TOC. |
| docs/patterns/messaging/message-translator.md | Adds pattern documentation for runtime, generated, and DI usage. |
| docs/guides/pattern-coverage.md | Updates coverage matrix to include Message Translator. |
| docs/generators/toc.yml | Adds Message Translator generator page to generator docs TOC. |
| docs/generators/messaging.md | Documents the new generator within the messaging generators guide. |
| docs/generators/message-translator.md | Adds dedicated generator documentation + diagnostics list. |
| docs/generators/index.md | Adds Message Translator to generator index and quick examples. |
| docs/examples/toc.yml | Adds the generated message translator example doc to examples TOC. |
| docs/examples/generated-message-translator.md | Adds example documentation for partner event normalization translator. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| cancellationToken.ThrowIfCancellationRequested(); | ||
| return await new ValueTask<MessageTranslationResult<TOutput>>(Translate(message, context)).ConfigureAwait(false); |
| public async ValueTask<MessageTranslationResult<TOutput>> TranslateAsync( | ||
| Message<TInput> message, | ||
| MessageContext? context = null, | ||
| CancellationToken cancellationToken = default) | ||
| { | ||
| cancellationToken.ThrowIfCancellationRequested(); | ||
| return await new ValueTask<MessageTranslationResult<TOutput>>(Translate(message, context)).ConfigureAwait(false); |
| sb.Append("abstract "); | ||
| else if (type.IsSealed && type.TypeKind == TypeKind.Class) | ||
| sb.Append("sealed "); | ||
| sb.Append("partial ").Append(type.TypeKind == TypeKind.Struct ? "struct" : "class").Append(' ').Append(type.Name).AppendLine(); |
| using PatternKit.Examples.VisitorDemo; | ||
| using PatternKit.Messaging.Routing; | ||
| using PatternKit.Messaging.Transformation; | ||
| using PatternKit.Structural.Decorator; |
🔍 PR Validation ResultsVersion: `` ✅ Validation Steps
📊 ArtifactsDry-run artifacts have been uploaded and will be available for 7 days. This comment was automatically generated by the PR validation workflow. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #246 +/- ##
==========================================
+ Coverage 91.18% 96.28% +5.10%
==========================================
Files 300 304 +4
Lines 28167 28459 +292
Branches 3921 3967 +46
==========================================
+ Hits 25684 27402 +1718
+ Misses 1109 1057 -52
+ Partials 1374 0 -1374
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Code Coverage |
Summary
Closes #233
Validation
Note: full examples build/test remains hosted-CI validated on this workstation because the local compiler rejects the current analyzer assembly with CS9057.